﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using DTO;
using DAO;

namespace BUS
{
    public class MatHangBUS
    {
        public List<MatHangDTO> HienThi()
        {
            MatHangDAO dao = new MatHangDAO();
            return dao.HienThi();
        }

        public int ThemMH(MatHangDTO dto)
        {
            MatHangDAO dao = new MatHangDAO();
            return dao.ThemMH(dto);
        }

        public int CapNhat(MatHangDTO dto)
        {
            MatHangDAO dao = new MatHangDAO();
            return dao.CapNhat(dto);
        }

        public int Xoa(MatHangDTO dto)
        {
            MatHangDAO dao = new MatHangDAO();
            return dao.Xoa(dto);
        }

        public int KiemTraMAMH(MatHangDTO dto)
        {
            MatHangDAO dao = new MatHangDAO();
            return dao.KiemTraMAMH(dto);
        }

        public int KiemTraKhacRong(MatHangDTO dto)
        {
            if (dto.MAMH == "")
            {
                return 0;
            }
            else if (dto.TENHANG == "")
            {
                return 1;
            }
            else if (dto.SOLUONGTON.ToString() == "")
            {
                return 2;
            }
            else
            {
                return 4;
            }
        }
    }
}
